<?php
/**
 * | ---------------------------------------------------------------------------------------------------
 * | Author：johnxu <fsyzxz@163.com>.
 * | ---------------------------------------------------------------------------------------------------
 * | Home: https://www.johnxu.net.
 * | ---------------------------------------------------------------------------------------------------
 * | Data: 2019-04-18
 * | ---------------------------------------------------------------------------------------------------
 * | Desc: 单列trait
 * | ---------------------------------------------------------------------------------------------------
 */

namespace johnxu\tool\traits;

trait Singleton
{
    private static $instance = null;

    public static function getInstance(array $config = []): self
    {
        if (!self::$instance instanceof self) {
            self::$instance = new static($config);
        }

        return self::$instance;
    }
}